home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume6 / uupoll < prev    next >
Encoding:
Text File  |  1989-03-06  |  5.0 KB  |  178 lines

  1. Newsgroups: comp.sources.misc
  2. Message-Id: <8902151819.AA14181@srhqla.UUCP>
  3. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  4. Reply-To: Michael M. Levin <srhqla!levin@uunet.UU.NET>
  5. Subject: v06i051: Uupoll
  6.  
  7. Posting-number: Volume 6, Issue 51
  8. Submitted-by: Michael M. Levin <srhqla!levin@uunet.UU.NET>
  9. Archive-name: uupoll
  10.  
  11. [I'm not certain I see the point in this, given "uucico -r1 -ssys".  ++bsa]
  12.  
  13. Uupoll is a utility which allows the user to force the polling of a
  14. remote system.  It has one option which allows the user to force the
  15. poll to actually start, rather than waiting for cron's next pass.  It
  16. is a Bourne shell-script, and is intended for use in HDB uucp systems.
  17. It is pretty well documented, and can easily be tailored to a specific
  18. system's unique requirements.  It follows the general style of other
  19. scripts pertaining to the uucp system, and follows (as much as I can
  20. tell) the same general approach as the stock poll handler for HDB (the
  21. one called uudemon.poll), which has to be started by cron.
  22.  
  23.  
  24. #! /bin/sh
  25. # This is a shell archive, meaning:
  26. # 1. Remove everything above the #! /bin/sh line.
  27. # 2. Save the resulting text in a file.
  28. # 3. Execute the file with /bin/sh (not csh) to create the files:
  29. #    Uupoll
  30. # This archive created: Wed Feb 15 10:17:34 1989
  31. export PATH; PATH=/bin:$PATH
  32. if test -f 'Uupoll'
  33. then
  34.     echo shar: will not over-write existing file "'Uupoll'"
  35. else
  36. cat << \SHAR_EOF > 'Uupoll'
  37. : #     Uupoll (1.0)
  38. : #
  39. : #    Bourne shell script to force polling of a remote system
  40. : #
  41. : #  Written by: 
  42. : #     Michael M. Levin - Feb, 1988
  43. : #
  44. : #                Copyright (c) 1988 
  45. : #                 Michael M. Levin
  46. : #    
  47. : #            (levin@srhqla.UUCP, levin@magnus.UUCP)
  48. : #    
  49. : #    
  50. : #    This script is intended for Public distribution. It shall
  51. : #    not be distributed in any manner whatsoever, nor packaged for 
  52. : #    enhancement to a commercial product in any form, for profit. 
  53. : #    This agreement also stipulates that the users of this script 
  54. : #    will not remove the names of the origional Author nor this
  55. : #    copyright notice from this script. 
  56. : #
  57. : #  Revision: Version 1.0 Feb 1988 
  58. : #
  59. : #    Developed for System V using HoneyDanBer uucp. 
  60. : #    (AT&T Basic Networking Utilities)
  61. : #
  62. : #     Last Updated:     Sat Feb 27 17:35:00 PST 1988
  63. : #
  64. : #  Usage:
  65. : #
  66. : #     This shell must be run by either super-user or uucp.
  67. : #    It causes a poll request to be entered (or touched, if
  68. : #    one already exists) for the specified system.  Even if
  69. : #    the file permissions are changed to allow execution by
  70. : #    other users, the shell will abort itself.
  71. : #    If the shell is started with only a system name, it simply
  72. : #    creates an entry which will be handled the next time that
  73. : #    uusched is run.  To also cause uusched to start up, start
  74. : #    it with a '-n' (NOW) option ahead of the system name.
  75. : #    For example:
  76. : #
  77. : #        Create entry only:    Uupoll sysname
  78. : #        Start uusched also:    Uupoll -n sysname
  79.  
  80. PATH=/bin:/usr/bin:/etc:/usr/lib/uucp
  81. export PATH
  82. SYS=/usr/lib/uucp/Systems    # Full pathname to Systems file(s)
  83. SPOOL=/usr/spool/uucp        # Mail system spool directory
  84. UUCP=uucp            # Local uid name for uucp (usually uucp)
  85. MAIL=mail            # Local gid name for mail (usually mail)
  86. ROOT=root            # Local uid name for root (usually root)
  87. NOW=NO
  88. USAGE="\tusage: ${0} [-n] sysname"
  89. umask 022
  90. set +e
  91.  
  92. : #    Determine that we are either uucp or root:
  93.  
  94.     if id|cut -f2 -d\(|cut -f1 -d\)|grep "^${UUCP}$" > /dev/null
  95.     then
  96.         continue
  97.     elif id|cut -f2 -d\(|cut -f1 -d\)|grep "^${ROOT}$" > /dev/null
  98.     then
  99.         continue
  100.     else
  101.         echo "${0}: you must be uucp to run this.  FAILED"
  102.         exit 2
  103.     fi
  104.  
  105.  
  106. : #    Verify that a system name has been passed to us:
  107.  
  108.     set -- `getopt n $*`
  109.     if [ $? != 0 ]
  110.     then
  111.         echo $USAGE
  112.         exit 2
  113.     fi
  114.     for i in $*
  115.     do
  116.         case $i in
  117.         -n)        NOW=YES; shift;; # Is 'NOW' flag set??
  118.         --)        shift; break;;
  119.         esac
  120.     done
  121.     if [ $# != 1 ]
  122.     then
  123.         echo "${0}: you must specify system name.  FAILED"
  124.         exit 2
  125.     fi
  126.  
  127.  
  128. : #    Make sure system name exists in our local Systems file:
  129.  
  130.     if uuname | grep "^${1}$" > /dev/null
  131.     then
  132.         site=$1
  133.         continue
  134.     else
  135.         echo "${0}: '"$1"' is not a valid system name.  FAILED"
  136.         exit 2
  137.     fi
  138.  
  139.  
  140. : #    If a spool directory doesn't exist for this system, create one.
  141.  
  142.     if [ ! -d $SPOOL/$site ]
  143.     then
  144.         mkdir $SPOOL/$site
  145.         chown $UUCP $SPOOL/$site
  146.         chgrp $MAIL $SPOOL/$site
  147.     fi
  148.  
  149.  
  150. : #    Create the poll entry in the specified system's spool directory.
  151.  
  152.     j=`expr $site : '\(.\{1,7\}\)'`
  153.     touch $SPOOL/$site/C.${j}n0000
  154.     chown $UUCP $SPOOL/$site/C.${j}n0000
  155.     chgrp $MAIL $SPOOL/$site/C.${j}n0000
  156.  
  157. : #    If NOW option selected, start the scheduler.
  158.  
  159.     if [ $NOW = YES ]
  160.     then
  161.         touch $SPOOL/.Status/$site
  162.         rm $SPOOL/.Status/$site
  163.         nohup uusched > /dev/null &
  164.         nohup uuxqt > /dev/null &
  165.     fi
  166. SHAR_EOF
  167. fi # end of overwriting check
  168. #    End of shell archive
  169. exit 0
  170.  
  171.  
  172.  
  173. -- 
  174. +----+         P L E A S E    R E S P O N D   T O:     +------+-*-*-*-*-*-*-*-*
  175. | Mike Levin, Silent Radio HeadQuarters, Los Angeles (srhqla) | No room for a *
  176. | Path:{aeras|csun|pacbell|pyramid|telebit}!srhqla!levin      |'snappy remark'*
  177. +-------------------------------------------------------------+-*-*-*-*-*-*-*-*
  178.